//
//  KDBlackSheetView.m
//  LaiKeDaoClient
//
//  Created by dongkedi的iMac on 15/11/11.
//  Copyright © 2015年 LKD. All rights reserved.
//

#import "KDBlackSheetView.h"

@implementation KDBlackSheetView

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        UIButton *btn3 = [self getButton];
        [btn3 setFrame:self.frame];
        [btn3 setTag:103];
        [btn3 setBackgroundColor:[UIColor colorWithHexString:@"aaaaaa"]];
        [btn3 setAlpha:0.4];
        [self addSubview:btn3];
        
        [self createUI];
    }
    return self;
}

- (void)createUI
{
    UIView      *backView = [[UIView alloc] initWithFrame:(CGRect){0,HEIGHT(self)-(27+15+44*2+10+30)-64,WIDTH(self),(27+15+44*2+10+30)}];
    [backView setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:backView];
    
    UILabel     *titleLabel= [[UILabel alloc] initWithFrame:(CGRect){0,14,WIDTH(self),15}];
    [titleLabel setTextAlignment:NSTextAlignmentCenter];
    [titleLabel setFont:[UIFont systemFontOfSize:15]];
    [titleLabel setBackgroundColor:[UIColor clearColor]];
    [titleLabel setTextColor:[UIColor blackColor]];
    [titleLabel setText:@"将此患者加入黑名单"];
    [backView addSubview:titleLabel];
    
    UIButton *btn1 = [self getButton];
    [btn1 setFrame:(CGRect){25,Y(titleLabel)+HEIGHT(titleLabel)+14,WIDTH(self)-50,44}];
    [btn1 setTitle:@"确 定" forState:UIControlStateNormal];
    [btn1 setBackgroundColor:kNavBlueColor];
    [btn1 setTag:101];
    [backView addSubview:btn1];
    
    
    UIButton *btn2 = [self getButton];
    [btn2 setFrame:(CGRect){X(btn1),Y(btn1)+HEIGHT(btn1)+10,WIDTH(btn1),HEIGHT(btn1)}];
    [btn2 setTitle:@"取 消" forState:UIControlStateNormal];
    btn2.layer.cornerRadius = 0;//设置那个圆角的有多圆
    btn2.layer.borderWidth = 1;//设置边框的宽度
    btn2.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    btn2.layer.masksToBounds = YES;
    [btn2.titleLabel setTextColor:[UIColor blackColor]];
    [btn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn2 setTag:102];
    [backView addSubview:btn2];
}

- (void)buttonClick:(UIButton *)btn
{
    if (btn.tag == 101) {
        //
    }else if (btn.tag == 102){
        
    }else if (btn.tag == 103){
        
    }
    if ([self.blackSheetDelegate respondsToSelector:@selector(chooseSheet:)]) {
        [self.blackSheetDelegate chooseSheet:btn.tag];
    }
}

- (UIButton *)getButton
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundColor:[UIColor clearColor]];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [button.titleLabel setFont:[UIFont systemFontOfSize:15]];
    return button;
}

@end
